import Vue from 'vue'
import Router from 'vue-router'
// import { getLocalStorage } from '@/assets/js/common'

Vue.use(Router)

// const checkToken = function (to, from, next) {
//   let token = getLocalStorage('token', 'string')
//   if (!token) {
//     next({
//       path: '/login'
//     })
//   } else {
//     next()
//   }
// }


const router = new Router({
    // mode: 'history',
    routes: [
        // { path: '/', redirect: '/map' },
        // { path: '/login', component: resolve => (require(["@/views/login/login"], resolve)), meta: { title: '登录页面' } },
        // { path: '/index', component: resolve => (require(["@/views/index/index"], resolve)), meta: { title: '北方基因' } },
        { path: '/', component: resolve => (require(["@/views/map/map"], resolve)), meta: { title: '大屏统计' } }

    ]
})


// 根据路由设置标题
router.beforeEach((to, from, next) => {
    /*路由发生改变修改页面的title */
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next();
})


export default router